{% extends 'myhome/index.html' %}
{% block title %}
<title>天天生鲜-商品详情</title>
{% endblock %}
{% block main %}
	<div class="navbar_con">
		<div class="navbar clearfix">
			<div class="subnav_con fl">
				<h1>全部商品分类</h1>	
				<span></span>			
				<ul class="subnav">
				{% for i in cate %}
					<li><a href="{% url 'myhome_goods_list' %}?fen={{i.id}}" class="fruit">{{i.name}}</a></li>
				{% endfor %}
				</ul>
			</div>
			<ul class="navlist fl">
				<li><a href="">首页</a></li>
				<li class="interval">|</li>
				<li><a href="">手机生鲜</a></li>
				<li class="interval">|</li>
				<li><a href="">抽奖</a></li>
			</ul>
		</div>
	</div>

	<div class="breadcrumb">
		<a href="#">全部分类</a>
		<span>></span>
		<a href="{% url 'myhome_goods_list' %}?fen={{data.id}}">{{data.cateid.name}}</a>
		<span>></span>
		<a href="{% url 'myhome_goods_list' %}">商品详情</a>
	</div>

	<div class="goods_detail_con clearfix">

		<div class="goods_detail_pic fl"><img src="{{data.pic_url}}" width="370"></div>
		<div class="goods_detail_list fr">
			<h3>{{data.title}}</h3>
			<p>{{data.info|safe}}</p>
			<div class="prize_bar">
				<span class="show_pirze">¥<em>{{data.price}}</em></span>
				<!-- <span class="show_unit">单  位：500g</span> -->
			</div>
			<div class="goods_num clearfix">
				<div class="num_name fl">数 量：</div>
				<div class="num_add fl">
					<input type="text" class="num_show fl aa" value=1>
					<a href="javascript:;" class="add fr">+</a>
					<a href="javascript:;" class="minus fr">-</a>	
				</div> 
			</div>
			<!-- <div class="total">总价：<em>16.80元</em></div> -->
			<div class="operate_btn">
				<a href="javascript:;" class="buy_btn">立即购买</a>
				<a href="javascript:;" class="add_cart" id="add_cart">加入购物车</a>				
			</div>
		</div>
	</div>
	<script type="text/javascript">
		// 点击立即购买
		$(".buy_btn").click(function(){
			var goodsid = '{{data.id}}'
			var num = $(".aa").val()
			$.get('{% url "myhome_cart_submit" %}',{"goodsid":goodsid,"num":num},function(data){
				if (data=="error"){
					alert("请登录!")
					$(window).attr("location","/myhome/login/?paths=/myhome/goodsInfo/&args={'id':'"+{{request.GET.id}}+"'}")
				}else{
					$(window).attr("location",data)
				}
			})
		})


		$("#add_cart").click(function(){
			s = '{{request.session.vipUser}}'
			if (!s){
				alert("请先登录")
				$(window).attr("location","/myhome/login/?paths=/myhome/goodsInfo/&args={'id':'"+{{request.GET.id}}+"'}")
				return 
			}
			gid = {{request.GET.id}}
			num = $(".num_add input").val()
			$.get('{% url "myhome_cart" %}',{"gid":gid,"num":num},function(data){
				if (!data.error){
					alert("添加购物车成功")
				}
			})
		})
	</script>

	<script type="text/javascript">
		$(".num_add a").click(function(){
			vals = $(".num_add input")
			val1 = parseInt(vals.val())
			if ($(this).index()==1){
				vals.val(val1+1)
			}else{
				if (val1>1){
					vals.val(val1-1)
				}
			}
		});
	</script>



	<div class="main_wrap clearfix">
		<div class="l_wrap fl clearfix">
			<div class="new_goods">
				<h3>新品推荐</h3>
				<ul>
					<li>
						<a href="#"><img src="/static/myhome/images/goods/goods001.jpg"></a>
						<h4><a href="#">进口柠檬</a></h4>
						<div class="prize">￥3.90</div>
					</li>
					<li>
						<a href="#"><img src="/static/myhome/images/goods/goods002.jpg"></a>
						<h4><a href="#">玫瑰香葡萄</a></h4>
						<div class="prize">￥16.80</div>
					</li>
				</ul>
			</div>
		</div>

		<div class="r_wrap fr clearfix">
			<ul class="detail_tab clearfix">
				<li class="active">商品介绍</li>
				<li>评论</li>
			</ul>

			<div class="tab_content">
				<dl>
					<dt>商品详情：</dt>
					<dd>草莓采摘园位于北京大兴区 庞各庄镇四各庄村 ，每年1月-6月面向北京以及周围城市提供新鲜草莓采摘和精品礼盒装草莓，草莓品种多样丰富，个大香甜。所有草莓均严格按照有机标准培育，不使用任何化肥和农药。草莓在采摘期间免洗可以直接食用。欢迎喜欢草莓的市民前来采摘，也欢迎各大单位选购精品有机草莓礼盒，有机草莓礼盒是亲朋馈赠、福利送礼的最佳选择。 </dd>
				</dl>
			</div>

		</div>
	</div>
	<div class="add_jump"></div>

	<script type="text/javascript" src="/static/myhome/js/jquery-1.12.4.min.js"></script>
	<!-- <script type="text/javascript">
		var $add_x = $('#add_cart').offset().top;
		var $add_y = $('#add_cart').offset().left;

		var $to_x = $('#show_count').offset().top;
		var $to_y = $('#show_count').offset().left;

		$(".add_jump").css({'left':$add_y+80,'top':$add_x+10,'display':'block'})
		$('#add_cart').click(function(){
			$(".add_jump").stop().animate({
				'left': $to_y+7,
				'top': $to_x+7},
				"fast", function() {
					$(".add_jump").fadeOut('fast',function(){
						$('#show_count').html(2);
					});

			});
		})
	</script> -->
	
{% endblock %}